import Vue from 'vue'
import Vuex from 'vuex'
import { login } from '../config/api'

Vue.use(Vuex)

const store = new Vuex.Store({
	state: { userInfo: uni.getStorageSync('userInfo') || null },
	getters: {},
	mutations: {
		setUser(state, payload) {
			state.userInfo = payload
			uni.setStorageSync('userInfo', payload)
		},
		upUserInfoData(state, payload){
			state.userInfo.name = payload.name
			state.userInfo.avatar = payload.avatar
			state.userInfo.desc = payload.desc
			state.userInfo.updatedAt = payload.updatedAt
			uni.setStorageSync('userInfo', state.userInfo)
		}
	},
	actions: {}
})

export default store
